package com.dailyblue.java.spring.boot.simple.example.handler;

import com.dailyblue.java.spring.boot.commons.bean.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//@RestControllerAdvice
@Slf4j
public class MyErrorHandler {

    @ExceptionHandler(NullPointerException.class)
    public JsonResult nullException() {
        return new JsonResult(false, 500, "出现了空指针情况", null);
    }
    @ExceptionHandler(ArithmeticException.class)
    public JsonResult byZoreException(){
        return new JsonResult(false,500,"除数不能为零",null);
    }
}
